<HTML>
<HEAD>
<TITLE> Preface</TITLE>
<META NAME="author" CONTENT="John Zukowski">
<META NAME="date" CONTENT="Thu Jul 31 14:19:57 1997">
<META NAME="form" CONTENT="html">
<META NAME="metadata" CONTENT="dublincore.0.1">
<META NAME="objecttype" CONTENT="book part">
<META NAME="otheragent" CONTENT="gmat dbtohtml">
<META NAME="publisher" CONTENT="O'Reilly &amp; Associates, Inc.">
<META NAME="source" CONTENT="SGML">
<META NAME="subject" CONTENT="Java AWT">
<META NAME="title" CONTENT="Java AWT">
<META HTTP-EQUIV="Content-Script-Type" CONTENT="text/javascript">
</HEAD>
<body vlink="#551a8b" alink="#ff0000" text="#000000" bgcolor="#FFFFFF" link="#0000ee">

<DIV CLASS=htmlnav>
<H1><a href='index.htm'><IMG SRC="gifs/smbanner.gif"
     ALT="Java AWT" border=0></a></H1>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top>&nbsp;</td>
<td width=171 align=center valign=top><B><FONT FACE="ARIEL,HELVETICA,HELV,SANSERIF" SIZE="-1">Preface</FONT></B></TD>
<td width=172 align=right valign=top><A HREF="ch00_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
</table>

&nbsp;
<hr align=left width=515>
</DIV>
<H1 CLASS=preface><A CLASS="TITLE" NAME="JAWT-PREF">Preface</A></H1>

<DIV CLASS=htmltoc>

<p>
<b>Contents:</b><br>
New Features of AWT in Java 1.1<br>
<A HREF="ch00_02.htm">What This Book Covers</A><BR>
<A HREF="ch00_03.htm">About the Source Code</A><BR>
<A HREF="ch00_04.htm">Other Java Books and Resources</A><BR>
<A HREF="ch00_05.htm">About Java</A><BR>
<A HREF="ch00_06.htm">Conventions Used in This Book</A><BR>
<A HREF="ch00_07.htm">Request for Comments</A><BR>
<A HREF="ch00_08.htm">Acknowledgments</A><BR>

<p>
</DIV>

<P CLASS=para>
The Abstract Window Tookit (AWT) provides the user interface for Java
programs.  Unless you want to construct your own GUI or use a crude
text-only interface, the AWT provides the tools you will use to
communicate with the user. Although we are beginning to see some other
APIs for building user interfaces, like Netscape's IFC (Internet
Foundation Classes), those alternative APIs will not be in widespread
use for some time, and some will be platform specific.  Likewise, we
are beginning to see automated tools for building GUIs in Java;
Sun's JavaBeans effort promises to make such tools much more
widespread. (In fact, the biggest changes in Java 1.1 prepare the way
for using the various AWT components as JavaBeans.) However, even with
automated tools and JavaBeans in the future, an in-depth knowledge of
AWT is essential for the practicing Java programmer.

<P CLASS=para>
The major problem facing Java developers these days is that AWT is a
moving target. Java 1.0.2 is being replaced by Java 1.1, with many
significant new features. Java 1.1 was released on February 18, 1997,
but it isn't clear how long it will take for 1.1 to be accepted
in the market. The problem facing developers is not just learning
about the new features and changes in Java 1.1, but also knowing when
they can afford to use these new features in their code.  In practice,
this boils down to one question: when will Netscape Navigator support
Java 1.1? Rumor has it that the answer is "as soon as
possible"--and we all hope this rumor is correct. But given
the realities of maintaining a very complex piece of software, and the
fact that Netscape is currently in the beta process for Navigator 4.0,
there's a possibility that "as soon as possible" and
"soon" aren't the same thing. In other words, you
should expect Java 1.0.2 to stick around for a while, especially since
Web users won't all replace their browsers as soon as Navigator has
1.1 support.

<P CLASS=para>
This state of affairs raises obvious problems for my book. Nothing would 
have made me happier than to write a book that covered AWT 1.1 only. It 
would be significantly shorter, for one thing, and I wouldn't have 
to spend so much effort pointing out which features are present in which 
release. But that's not the current reality. For the time being, 
programmers still need to know about 1.0.2. Therefore, this book covers 
both releases thoroughly. There are many examples using 1.0.2; many more 
examples that require 1.1; and more examples showing you how to update 
1.0.2 code to use 1.1's features. 

<P CLASS=para>
Sun has done a good job of maintaining compatibility between versions: 
1.0 code runs under Java 1.1, with very few exceptions. All of the 1.0 
examples in this book have been tested under Java 1.1. However, Java 1.1--and 
particularly, AWT 1.1--offer many advantages over older releases. 
If nothing else, I hope this book convinces you that you should be looking 
forward to the day when you can forget about writing code for Java 1.0.2. 

<DIV CLASS=sect1>
<h2 CLASS=sect1><A CLASS="TITLE" NAME="JAWT-PREF-SECT-1">New Features of AWT in Java 1.1</A></h2>

<P CLASS=para>
Having spent all this time talking about 1.0.2 and 1.1 and the transitional 
state we're currently in and having alluded briefly to the advantages 
of Java 1.1, you deserve a brief summary of what has changed. Of course, you'll 
find the details in the book. 

<P>
<DL CLASS=variablelist>
<DT CLASS=varlistentry><I CLASS=emphasis>Improved event handling</I><br>
<DD>

<P CLASS=para>
Java 1.1 provides a completely new event model. Instead of propagating 
events to all objects that might possibly have an interest, objects in
Java 1.1 register their interest in particular kinds of events and 
get only the events they're interested in hearing. The old event model 
is still supported, but the new model is much more efficient. 

<P CLASS=para>
The new event model is also important in the context of JavaBeans. The 
old events were pretty much specific to AWT. The new model has been designed 
as a general purpose feature for communication between software components. 
Unfortunately, how to use events in this more general sense is beyond the 
scope of this book, but you should be aware that it's possible. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>New components and containers</I><br>
<DD>

<P CLASS=para>
Java 1.1 provides one new component, the <tt CLASS=literal>PopupMenu</tt>, 
and one new container, the <tt CLASS=literal>ScrollPane</tt>. 
Pop-up menus are a staple of modern user interfaces; providing them fixes 
a serious omission. <tt CLASS=literal>ScrollPane</tt> 
makes it trivial to implement scrolling; in Java 1.0, you had to do scrolling 
"by hand." In Java 1.1, you also get menu shortcuts (i.e., 
the ability to select menu items using the keyboard), another standard 
feature of modern user interfaces. 

<P CLASS=para>
Java 1.1 also introduces a <tt CLASS=literal>LightweightPeer</tt>, 
which means that it is possible to create "lightweight components." 
To do so, you subclass <tt CLASS=literal>Component</tt> 
or <tt CLASS=literal>Container</tt> directly; this 
wasn't possible in earlier releases. For simple operations, lightweight 
components are much more efficient than full-fledged components. 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>Clipboards</I><br>
<DD>

<P CLASS=para>
Java 1.1 lets you read from and write to the system clipboard and create 
private clipboards for use by your programs. The clipboard facility is 
a down payment on a larger data transfer facility, which will support drag 
and drop. (No promises about when drag and drop will appear.) 

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>Printing</I><br>
<DD>

<P CLASS=para>
Java 1.1 gives components the ability to print.

<p>
<DT CLASS=varlistentry><I CLASS=emphasis>The rest</I><br>
<DD>

<P CLASS=para>
There are many other new features, including more flexible use of cursors; 
the ability to use system color schemes, and thus make your program look 
like other software in the run-time environment; more image filters to play 
with; and the ability to prescale an image. </DL>
<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JAWT-PREF-SECT-1.1">Deprecated Methods and JavaBeans</A></h3>

<P CLASS=para>
One of the biggest changes in Java 1.1 doesn't concern the feature 
set at all. This was the addition of many new methods that differ from 
a method of Java 1.0 in name only. There are hundreds of these, particularly 
in AWT. The new method names show an important future direction for the 
AWT package (in fact, all of Java). The new names obey the naming conventions 
used by JavaBeans, which means that all AWT classes are potentially Beans. 
These conventions make it possible for an application builder to analyze 
what a component does based on its public methods. For example, the method 
<tt CLASS=literal>setFont()</tt> changes the value 
of the component's <tt CLASS=literal>Font</tt> 
property. In turn, this means that you will eventually be able to build 
user interfaces and, in some cases, entire applications, inside some other 
tool, without writing any Java code at all. An application builder will 
be able to find out what it needs to know about any component by looking 
at the component itself, and letting you customize the component and its 
interactions with others. 

<P CLASS=para>
Comments in the JDK source code indicate that the older method names have 
been "deprecated," which means that you should consider the 
old names obsolete and avoid using them; they could disappear in a future 
release.

<P CLASS=para>
Reworking AWT to comply with JavaBeans is both necessary and
inevitable. Furthermore, it's a good idea to get into the habit of following the same
conventions for your own code; the advantages of JavaBeans are much
greater than the inconvenience of changing your coding style.

</DIV>

<DIV CLASS=sect2>
<h3 CLASS=sect2><A CLASS="TITLE" NAME="JAWT-PREF-SECT-1.2">Other Changes in Java</A></h3>

<P CLASS=para>
Other new features are scattered throughout the rest of the Java 
classes, most notably, improvements in the networking and I/O packages 
and support for internationalization. Some new features were added to the 
language itself, of which the most important is "inner classes." 
For the most part, I don't discuss these changes; in fact, I stay 
away from them and base non-AWT code on the 1.0.2. release. Though these 
changes are important, covering the new material in AWT is enough for one 
book. If I used a new feature at this point, I would feel that I owed 
you an explanation, and this book is already long enough. A future edition 
will update the code so that it doesn't rely on any older features. 

</DIV>

</DIV>


<DIV CLASS=htmlnav>

<P>
<HR align=left width=515>
<table width=515 border=0 cellpadding=0 cellspacing=0>
<tr>
<td width=172 align=left valign=top>&nbsp;</td>
<td width=171 align=center valign=top><a href="index.htm"><img src='gifs/txthome.gif' border=0 alt='Home'></a></td>
<td width=172 align=right valign=top><A HREF="ch00_02.htm"><IMG SRC="gifs/txtnexta.gif" ALT="Next" border=0></A></td>
</tr>
<tr>
<td width=172 align=left valign=top>&nbsp;</td>
<td width=171 align=center valign=top><a href="index/idx_a.htm"><img src='gifs/index.gif' alt='Book Index' border=0></a></td>
<td width=172 align=right valign=top>What This Book Covers</td>
</tr>
</table>
<hr align=left width=515>

<IMG SRC="gifs/smnavbar.gif" USEMAP="#map" BORDER=0> 
<MAP NAME="map"> 
<AREA SHAPE=RECT COORDS="0,0,108,15" HREF="../javanut/index.htm"
alt="Java in a Nutshell"> 
<AREA SHAPE=RECT COORDS="109,0,200,15" HREF="../langref/index.htm" 
alt="Java Language Reference"> 
<AREA SHAPE=RECT COORDS="203,0,290,15" HREF="../awt/index.htm" 
alt="Java AWT"> 
<AREA SHAPE=RECT COORDS="291,0,419,15" HREF="../fclass/index.htm" 
alt="Java Fundamental Classes"> 
<AREA SHAPE=RECT COORDS="421,0,514,15" HREF="../exp/index.htm" 
alt="Exploring Java"> 
</MAP>
</DIV>

</BODY>
</HTML>
